﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CommonHelper.VersionCheckProxy;

namespace SQLIOSimParser
{
    public partial class AvailableUpdateForm : Form
    {
        public AvailableUpdateForm()
        {
            InitializeComponent();
        }

        private string LinkUrl;

        public AvailableUpdateForm(string CurrentVersion, VersionCheckResponse resp):this()
        {
            lblCurrentVersion.Text = CurrentVersion;
            lblMessage.Text = resp.PublishMessage;

            if (resp.PublishUrl.Contains("http://") || resp.PublishUrl.Contains("mailto:"))
            {
                lblLinkurl.Text = "Get the new version";
                LinkUrl = resp.PublishUrl;
            }
            else
            {
                lblLinkurl.Text = resp.PublishUrl;
                lblLinkurl.Enabled = false;
            }

            lblRecentVersion.Text = resp.VersionNumber;
            lblPublishDate.Text = resp.PublishDate.ToLongDateString();
        }

        private void lblLinkurl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (LinkUrl.Contains("http://") || LinkUrl.Contains("mailto:"))
                System.Diagnostics.Process.Start(LinkUrl);
        }
    }
}
